<template>
    <div class="createQuestion">
      <header>添加工厂</header>
      <div class="content">
        <el-checkbox-group v-model="chooseList">
          <div v-for="item in factoryList">
            <el-checkbox :label="item"></el-checkbox>
          </div>
        </el-checkbox-group>
      </div>
      <footer>
        <div class="buttons but1" @click="close">取消</div>
        <div class="buttons but2" @click="addQuestion">确认</div>
      </footer>
    </div>
</template>

<script>
  import {mapActions} from 'vuex'
  export default {
    props:['factorys'],
    name: "chooseFactory",
    data() {
      return {
        factoryList: [],
        chooseList: [],
      }
    },
    created() {
      let self = this
      self.$http.get(self.conURL + 'mongo/api/docs/dictitem/factory').then(res => {
        self.factoryList = res.data
        for (let i = 0; i < self.factorys.length; i++){
          self.chooseList.push(self.factorys[i].name)
        }
      })
    },
    mounted() {
    },
    methods: {
      ...mapActions([
        'upstate'
      ]),
      //取消
      close(){
        let self = this
        self.upstate({key:'showChooseFactory',val:false})
      },
      //确定
      addQuestion(){
        let self = this
        self.upstate({key:'showChooseFactory',val:false})
        this.$emit('chooseBack',self.chooseList);
      },
    }
  }
</script>

<style lang="less">
  .createQuestion{
    width: 660px;
    height: 100%;
    background: #fff;
    border-left: 1px solid #e5e5e5;
    box-shadow: #eeeeee 0px 0px 15px;
    position: absolute;
    right: 0;
    top: 0;
    z-index: 9;
    header{
      width: 100%;
      height: 74px;
      line-height: 74px;
      border-bottom: 1px solid #e5e5e5;
      padding: 0 30px;
      box-sizing: border-box;
      font-size: 20px;
      color: #222222;
    }
    .content{
      width: 100%;
      display: flex;
      flex-direction: column;
      padding: 32px 28px;
      box-sizing: border-box;
      textarea{
        width: 100%;
        height: 220px;
        font-size: 14px;
        resize: none;
        overflow-y:auto;
        padding: 12px;
        box-sizing: border-box;
      }
    }
    footer{
      width: 100%;
      height: 59px;
      background: #fafafa;
      border-top: 1px solid #e5e5e5;
      position: absolute;
      right: 0;
      bottom: 0;
      display: flex;
      flex-direction: row;
      justify-content: center;
      .buttons{
        width: 93px;
        height: 37px;
        line-height: 39px;
        text-align: center;
        font-size: 16px;
        margin: auto 0;
        cursor: pointer;
      }
      .but1{
        background: #fff;
        color: #666666;
        border: 1px solid #dddddd;
        margin-right: 10px;
      }
      .but2{
        background: #0f76c8;
        color: #fff;
        border: 1px solid #0f76c8;
      }
    }
  }
</style>
